Skip to content

Build dpctl with scikit-build-core - #2345

Open
ndgrigorian wants to merge 11 commits into
masterfrom
feature/build-with-scikit-build-core
Open

ndgrigorian wants to merge 11 commits into
masterfrom
feature/build-with-scikit-build-core

Conversation

@ndgrigorian

@ndgrigorian ndgrigorian commented Jul 28, 2026 •

Copy link
Copy Markdown
Collaborator

This PR proposes building dpctl instead with scikit-build-core, upgrading from scikit-build to the more modern build system, and computing the version with setuptools-scm instead of versioneer

It includes the commits from gh-2388 (by @henryiii), rebased onto master, with the conda recipe, CHANGELOG and workflows adapted to the changes on master since; the examples are built with scikit-build-core as well, with a minimal pyproject.toml each, and use_dpctl_sycl_kernel installs its SPIR-V resources inside the package

scikit-build 1.0 broke the setup.py build_ext builds in CI; gh-2438 pins it below 1.0 until this PR is merged

  • Have you provided a meaningful PR description?
  • Have you added a test, reproducer or referred to an issue with a reproducer?
  • Have you tested your changes locally for CPU and GPU devices?
  • Have you made sure that new changes do not introduce compiler warnings?
  • Have you checked performance impact of proposed changes?
  • Have you added documentation for your changes, if necessary?
  • Have you added your changes to the changelog?
  • If this PR is a work in progress, are you opening the PR as a draft?

@ndgrigorian
ndgrigorian force-pushed the feature/build-with-scikit-build-core branch from fd7a5c2 to 2f74475 Compare November 5, 2026 17:43
@ndgrigorian ndgrigorian mentioned this pull request Dec 2, 2026
1 of 8 tasks
@ndgrigorian
ndgrigorian force-pushed the feature/build-with-scikit-build-core branch from 2f74475 to 1c2f892 Compare December 2, 2026 22:59
@github-actions

github-actions Bot commented Dec 2, 2026

Copy link
Copy Markdown

@ndgrigorian
ndgrigorian force-pushed the feature/build-with-scikit-build-core branch from 1c2f892 to 0357abf Compare December 2, 2026 23:03
@coveralls

coveralls commented Dec 2, 2026 •

Copy link
Copy Markdown
Collaborator

Coverage Status

coverage: 75.171% (-0.01%) from 75.182% — feature/build-with-scikit-build-core into master

@henryiii

henryiii commented Dec 2, 2026

Copy link
Copy Markdown

Sorry about the breakage! But I did give several months warning. :)

@ndgrigorian

Copy link
Copy Markdown
Collaborator Author

Sorry about the breakage! But I did give several months warning. :)

It's no problem, your commits were quite helpful regardless of anything (especially with versioning). The PR to pin in CI for the time being is also open. :)

@ndgrigorian
ndgrigorian marked this pull request as ready for review December 2, 2026 23:14
@ndgrigorian
ndgrigorian force-pushed the feature/build-with-scikit-build-core branch from 2d16bc4 to e520a55 Compare December 2, 2026 23:33
henryiii and others added 11 commits December 4, 2026 08:52
Replace the setup.py build (which uses skbuild.setuptools_wrap internals)
with scikit-build-core, and versioneer with setuptools-scm.

Closes #2341.

Assisted-by: ClaudeCode:claude-opus-5-5
Assisted-by: ClaudeCode:claude-opus-5-5
Find installed data next to a compiled module, since editable installs
keep Python files in the source tree. Clear the VS generator platform
and toolset in bld.bat, which Ninja rejects.

Assisted-by: ClaudeCode:claude-opus-5-5
The loop over the undefined _sources set no options.
They install with the extension, so example.py and the tests find them in
editable and regular installs alike.
Install scikit-build-core in the Windows open-source compiler workflow.
With the Visual Studio generator, the default on Windows, CMake uses MSVC
regardless of CC and CXX.
With -w, cython writes its depfile relative to the source directory, which
fails when the temporary build directory is on another drive.
Build the AdaptiveCpp examples with pip and point the C-API test
steps at the scikit-build-core build directory.
@ndgrigorian
ndgrigorian force-pushed the feature/build-with-scikit-build-core branch from fe55ce3 to 4bf1217 Compare December 4, 2026 17:06
Comment thread pyproject.toml
__version__ = version = "${version}"
'''

[tool.setuptools_scm]

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Blocking: With its default version scheme, setuptools-scm fails on any commit after a X.Y.ZdevN tag with N ≥ 1, and dpctl makes such tags every cycle (0.22.0dev1, 0.23.0dev1). After the next 0.24.0dev1, pip install ., conda-build and cibuildwheel would all fail:

git tag 0.24.0dev1 HEAD~3
python -m setuptools_scm  # ValueError: ... The 0.24.0.dev1 can't be bumped
git tag -d 0.24.0dev1

With version_scheme = "post-release" under [tool.setuptools_scm] the same commit gets 0.24.0.dev1.post3+g<sha>.

Comment thread dpctl/CMakeLists.txt
# -w is to set working directory (and correctly set __pyx_f[] array of filenames)
set(CYTHON_FLAGS "-t -w \"${CMAKE_SOURCE_DIR}\"")
find_package(Cython REQUIRED)
set(CYTHON_ARGS -t -w "${CMAKE_SOURCE_DIR}")

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With -w, Cython writes the depfile relative to the source root, but Ninja reads it relative to the build dir and tracks dpctl/dpctl/_sycl_device.pxd, which does not exist. Every build re-runs Cython for all modules, and with -t a changed .pxd still does not regenerate the modules that cimport it. With set(CYTHON_ARGS) the deps work and __pyx_f[] stays dpctl/_sycl_queue.pyx. The examples use the same flags.

Comment thread pyproject.toml
[tool.scikit-build]
build-dir = "build/{wheel_tag}"
metadata.version.provider = "scikit_build_core.metadata.setuptools_scm"
minimum-version = "build-system.requires"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Without cmake>=3.29.0 in requires, scikit-build-core takes the minimum from cmake_minimum_required(VERSION 3.21...) and accepts a system CMake 3.22 (Ubuntu 22.04). The pybind11 FetchContent_Declare(... FIND_PACKAGE_ARGS ...) needs 3.24, so configure fails with URL_HASH is set to SHA256=...;FIND_PACKAGE_ARGS;NAMES;pybind11 but must be ALGO=value. cmake.version = ">=3.29" here would keep the old minimum.

set(LZ_DIR "${CMAKE_CURRENT_BINARY_DIR}/level-zero")

if(EXISTS "${CMAKE_BINARY_DIR}/level-zero/.git")
if(EXISTS ${LZ_DIR})

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

EXISTS ${LZ_DIR} is also true for a level-zero directory without .git. Then git fetch, describe and checkout run in the dpctl checkout itself, as the build dir is inside it: with an empty level-zero, the dpctl tree ends detached at its latest tag and configure fails on zet_api.h. Could it keep the .git check and the file(REMOVE_RECURSE ...) before the clone?

Comment on lines +117 to +119
set CC=icx
set CXX=icx
python -m pip install --no-build-isolation .

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On Windows, scikit-build-core uses CMake's default generator, Visual Studio, unless CMAKE_GENERATOR is set, and that generator ignores CC and CXX (the examples' pyproject.toml says so too). So these commands would build with MSVC. Adding set CMAKE_GENERATOR=Ninja would match what build_locally.py and bld.bat do.

Comment thread .gitignore
# CMake build and local install directory
build
_skbuild
build_cmake

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Existing checkouts keep their _skbuild/ tree, which now shows up in git status, and the sdist packs it, since scikit-build-core follows .gitignore. Keeping _skbuild here avoids both.

Comment thread CHANGELOG.md
* Changed the development packages on `dppy/label/dev` to build against conda-forge only, and the wheels there to declare `intel-sycl-rt` and `intel-cmplr-lib-rt` in their metadata, at least the compiler version they were built with [gh-2409](https://github.com/IntelPython/dpctl/pull/2409)
* Changed the conda recipe's tests to `pip check`, the import and `python -m dpctl -f`, as in the conda-forge feedstock, so `conda build` and `conda build --test` no longer run the test suite; run it with `ci/hooks.py`, or with `python -m pytest --pyargs dpctl` in an environment with dpctl installed [gh-2409](https://github.com/IntelPython/dpctl/pull/2409)
* Changed the install instructions in `README.md` and the documentation to conda-forge and PyPI [gh-2409](https://github.com/IntelPython/dpctl/pull/2409)
* Build with `scikit-build-core` instead of `scikit-build` and `setuptools`, and compute the version with `setuptools-scm` instead of `versioneer` [gh-2345](https://github.com/IntelPython/dpctl/pull/2345)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: This line could also say what changes for developers: setup.py is gone (build with pip install ., add -e to develop), and build_locally.py --skip-editable now installs dpctl into the environment instead of building in place.

Comment thread conda-recipe/meta.yaml
- setuptools-scm >=8
- cython-cmake >=0.2
- cython >=3.1.0 # [py>=313]
- cython >=3.0.10 # [py<313]

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: CMake now requires Cython 3.1 (find_package(Cython MODULE REQUIRED VERSION 3.1)), so this could be cython >=3.1.0 for every Python, as in pyproject.toml.

Comment thread dpctl/CMakeLists.txt
cmake_parse_arguments(BUILD_DPCTL_EXT "${options}" "RELATIVE_PATH" "" ${ARGN})
add_cython_target(${_trgt} ${_src} CXX OUTPUT_VAR _generated_src)
set(_cythonize_trgt "${_trgt}_cythonize_pyx")
cython_transpile(${_src} LANGUAGE CXX OUTPUT_VARIABLE _generated_src)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: scikit-build's add_cython_target passed --gdb --line-directives for Debug and RelWithDebInfo builds; cython_transpile does not. So build_locally.py --debug now gives .cxx files without #line back to the .pyx, and gdb steps through generated C++. Appending these flags to CYTHON_ARGS for those build types would keep it.

Comment thread scripts/_build_helper.py
env=env,
cwd=setup_dir,
)
cmd.append(f"--config-settings=cmake.args={';'.join(cmake_args)}")

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: scikit-build-core splits cmake.args on ; again, so a CMake list in --cmake-opts breaks: -DCMAKE_PREFIX_PATH=/opt/a;/opt/b reaches CMake as -DCMAKE_PREFIX_PATH=/opt/a and /opt/b. Passing the options in the CMAKE_ARGS environment variable, which is split on spaces, keeps them whole.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants